package 字符串.最后一个单词的长度58;

import utils.Utils;

public class Solution {
    public static int lengthOfLastWord(String s) {
        if(s.length() < 1){
            return 0;
        }
        int res = 0;
        for(int i=s.length()-1;i>=0;i--){
            if(Character.isLetter(s.charAt(i))){
                res++;
            }else if(res == 0){
                continue;
            }else{
                break;
            }
        }

        return res;
    }
    public static void main(String[] args) {
        String  str  = "fly me   to   the moon   ";
        Utils.printInt(lengthOfLastWord(str));
    }
}
